def all_ward(n):
    while n > 0:
        if n % 16 < 10:
            return False
        n //= 16
    return True

for i in range(2022, 10**5):
    if all_ward(i):
        print(i)
        break